home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 December / PCWorld_2007-12_cd.bin / domacnost a kancelar / autoit / autoit-v3-setup.exe / Examples / Helpfile / GUICtrlGetHandle.au3 < prev    next >
Text File  |  2007-09-08  |  2KB  |  67 lines

  1. #include <GUIConstants.au3>
  2.  
  3. Global Const $MIM_APPLYTOSUBMENUS    = 0x80000000
  4. Global Const $MIM_BACKGROUND        = 0x00000002
  5.  
  6.  
  7. $hGui            = GUICreate("My GUI", 300, 200)
  8.  
  9. $FileMenu        = GUICtrlCreateMenu("&File")
  10. $OpenItem        = GUICtrlCreateMenuItem("&Open", $FileMenu)
  11. $SaveItem        = GUICtrlCreateMenuItem("&Save", $FileMenu)
  12. GUICtrlCreateMenuItem("", $FileMenu)
  13.  
  14. $OptionsMenu    = GUICtrlCreateMenu("O&ptions", $FileMenu)
  15. $ViewItem        = GUICtrlCreateMenuItem("View", $OptionsMenu)
  16. GUICtrlCreateMenuItem("", $OptionsMenu)
  17. $ToolsItem        = GUICtrlCreateMenuItem("Tools", $OptionsMenu)
  18.  
  19. GUICtrlCreateMenuItem("", $FileMenu)
  20. $ExitItem        = GUICtrlCreateMenuItem("&Exit", $FileMenu)
  21.  
  22. $HelpMenu        = GUICtrlCreateMenu("&?")
  23. $AboutItem        = GUICtrlCreateMenuItem("&About", $HelpMenu)
  24.  
  25. $EndBtn            = GUICtrlCreateButton("End", 110, 140, 70, 20)
  26.  
  27. SetMenuColor($FileMenu, 0xEEBB99)    ; BGR color value
  28. SetMenuColor($OptionsMenu, 0x66BB99); BGR color value
  29. SetMenuColor($HelpMenu, 0x99BBEE)    ; BGR color value
  30.  
  31. GUISetState()
  32.  
  33. While 1
  34.     $Msg = GUIGetMsg()
  35.     
  36.     Switch $Msg
  37.         Case $EndBtn, $GUI_EVENT_CLOSE
  38.             ExitLoop
  39.         
  40.         Case $AboutItem
  41.             Msgbox(64, "About...", "Colored menu sample")
  42.     EndSwitch    
  43. WEnd
  44.     
  45. Exit
  46.  
  47.  
  48. ; Apply the color to the menu
  49. Func SetMenuColor($nMenuID, $nColor)
  50.     ; Minimum OS are Windows98 and 2000 
  51.     If @OSVersion = "WIN_95" Or @OSVersion = "WIN_NT4" Then Return
  52.     
  53.     $hMenu    = GUICtrlGetHandle($nMenuID)
  54.     
  55.     $hBrush    = DllCall("gdi32.dll", "hwnd", "CreateSolidBrush", "int", $nColor)
  56.     $hBrush    = $hBrush[0]
  57.         
  58. Local $stMenuInfo = DllStructCreate("dword;dword;dword;uint;dword;dword;ptr")
  59.     DllStructSetData($stMenuInfo, 1, DllStructGetSize($stMenuInfo))
  60.     DllStructSetData($stMenuInfo, 2, BitOr($MIM_APPLYTOSUBMENUS, $MIM_BACKGROUND))
  61.     DllStructSetData($stMenuInfo, 5, $hBrush)
  62.     
  63.     DllCall("user32.dll", "int", "SetMenuInfo", "hwnd", $hMenu, "ptr", DllStructGetPtr($stMenuInfo))
  64.     
  65.     ; release Struct not really needed as it is a local 
  66.     $stMenuInfo = 0
  67. EndFunc